import config from "../../config"

export default new (class ScorePanel {
  score = -1
  level = 0
  upScore = config.score.upScore
  maxLevel = config.score.maxLevel

  // 分数和等级的dom
  scoreDom: HTMLSpanElement
  levelDom: HTMLSpanElement

  constructor() {
    this.scoreDom = document.getElementById('score')!
    this.levelDom = document.getElementById('level')!
    this.setScore()
  }

  // 设置分数和等级
  setScore() {
    this.score ++
    if (this.score % this.upScore === 0 && this.level < this.maxLevel) {
      this.level ++
    }
    this.scoreDom.innerText = this.score.toString()
    this.levelDom.innerText = this.level.toString()
  }
})
